var appApiUrl = '/api'
var accesskey = '123456'

//网站统一接口
export function sendRequest(url, method, data) {
	const androidUrl = 'https://video.3r8.cn' + url
	return new Promise((reresolve, reject) => {
		uni.request({
			url: androidUrl,
			method: method,
			data: {
				ajax: 1,
				key: accesskey,
				...data
			},
			dataType: 'json',
			header: {
				'content-type': 'application/x-www-form-urlencoded'
			},
			success: (data) => {
				reresolve(data)
			},
			fail: () => {
				uni.showToast({
					title: '系统内部错误，请联系管理员',
					icon: 'none',
				})
				reject(data);
			}
		})
	})
}

/**
 * 第三方以及自定义接口
 */
export function sendRequestApi(url, method, data) {
	return new Promise((reresolve, reject) => {
		uni.request({
			url: url,
			header: {
				'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
			},
			method: method,
			data: {
				...data
			},
			success: (data) => {
				reresolve(data)
			},
			fail: () => {
				uni.showToast({
					title: '系统内部错误，请联系管理员',
					icon: 'none',
				})
				reject(data);
			}
		})
	})
}